<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require 'db_con.php';
$username=$_REQUEST['username'];
$sex=$_REQUEST['sex'];
$imgurl=$_REQUEST['imgurl'];
$message=$_REQUEST['message'];
date_default_timezone_get('Asia/Shanghai');
$mdate=date("Y-m-d h:i:s");
$sql="INSERT INTO t_message(username,sex,message,imgurl,m_date) VALUES('{$username}','{$sex}','{$message}','{$imgurl}','{$mdate}')";
$rs=$db->query($sql);
$db->close();
if ($rs==true)
{
    echo "<script type='text/javascript'>";
    echo "window.location.href='index.php' ";
    echo"</script>";
}
else{
    echo "<script type='text/javascript'>";
    echo "alert('留言失败！'); ";
    echo "window.location.href='index.php' ";
    echo"</script>";
}